/*
package com.mty.predicates;


import org.springframework.cloud.gateway.handler.predicate.AbstractRoutePredicateFactory;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.server.ServerWebExchange;

import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

*/
/**
 * @author ：Teacher马（2508531326@qq.com）
 * @date ：Created in 2022/11/21 17:31
 * @description：
 * @modified By：
 * @version:
 *//*

@Component
public class AgeRoutePredicateFactory extends AbstractRoutePredicateFactory<AgeRoutePredicateFactory.Config> {


    public AgeRoutePredicateFactory() {
        super(AgeRoutePredicateFactory.Config.class);
    }

    @Override
    public List<String> shortcutFieldOrder() {
        return Arrays.asList("minAge","maxAge");
    }
    @Override
    public Predicate<ServerWebExchange> apply(Config config) {
        return (serverWebExchange -> {
            ServerHttpRequest request = serverWebExchange.getRequest();
            String age = request.getHeaders().getFirst("age");
            if(StringUtils.hasText(age)){
                int a =Integer.parseInt(age);
                if (a>config.getMinAge()&&a<config.getMaxAge()){
                    return true;
                }
            }
            return  false;
        });
    }




    @Validated
    public  static  class  Config{
        @NotNull
        private  int minAge;
        @NotNull
        private  int maxAge;

        public int getMinAge() {
            return minAge;
        }

        public void setMinAge(int minAge) {
            this.minAge = minAge;
        }

        public int getMaxAge() {
            return maxAge;
        }

        public void setMaxAge(int maxAge) {
            this.maxAge = maxAge;
        }
    }
}
*/
